<!DOCTYPE html>
 <meta charset="UTF-8"> 
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-125261808-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'UA-125261808-1');
</script>

<link href='https://fonts.googleapis.com/css?family=Roboto Condensed' rel='stylesheet'>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
        margin-top: 5vw;
        margin-left: 10vw;
        margin-right: 10vw;
       	padding: 0;
        font-size: 100%;
        font-family: 'Roboto Condensed', 'Tahoma', 'Arial', sans-serif;
}

#introduction {
   text-align: justify;
}


table.maintable {
   table-layout: fixed;
   border: 0px solid black;
}

table.maintable td {
   padding-right: 2vw;
   padding-left: 0.2vw;
}


   ul.tree, ul.tree ul {
     list-style-type: none;
     background:  repeat-y;
     margin: 0;
     padding: 0;
     margin: 1vw;
   }

   ul.tree ul {
     list-style-type: none;
     margin-left: 5vw;
   }


  ol li {
     list-style-type: decimal;
     margin-left: 0px;
   }

a {
    color: black;
}

   ul.tree li {
     margin: 1vw;
     padding: 0 5vw;
     line-height: 5vw;
     color: #369;
   }

   ul.tree li.last {
     background: no-repeat;
   }

ul.topnav {
    list-style-type: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    background-color: #333;
    font-size: 1.5vw;
    text-align: center;
}

ul.topnav li {float: left;
     list-style-type: none;
}

ul.topnav li a {
    display: block;
    color: white;
    text-align: center;
    padding: 0.2vw 0.0cm;
    width: 8.5vw;
    text-decoration: none;
    font-size: 1.2vw;
}


ul.topnav li a:hover:not(.active) {background-color: #111;color: white}
ul.topnav li a:hover {color: white}

ul.topnav li a.active {background-color: rgb(44, 173, 46);}
ul.topnav li.right {float: right;}

img.logo {max-width: 25vw;}

pre, code { font-size:100%; background:#eeeeee; margin:5vw 0px 5vw; }
tt { font-size: 0.5cm; }
pre { margin:0px 1vw 1vw; white-space: pre-wrap;}
pre.codeinput { padding:5vw; border:0.1vw margin:5vw 0px 5vw; solid #d3d3d3; background:#eeeeee; }
pre.codeoutput { padding:5vw; 5vw; margin:5vw 0px 5vw; color:#4c4c4c; }
pre.error { color:red; }

@media print { pre.codeinput, pre.codeoutput { word-wrap:break-word; width:100%; } }

span.keyword { color:#0000FF }
span.comment { color:#228B22 }
span.string { color:#A020F0 }
span.untermstring { color:#B20000 }
span.syscmd { color:#B28C00 }

.footer {  width: 100%;  padding:5vw 0px; margin:5vw 0px 0px; border-top:1px dotted #878787; font-size:0.8em; line-height:140%; font-style:italic; color:#878787; text-align:left; float:none; }
.footer p { margin:0px; }
.footer a { color:#878787; }
.footer a:hover { color:#878787; text-decoration:underline; }
.footer a:visited { color:#878787; }

   li {
     list-style-type: square;
     background:  repeat-y;
     padding: 0;
   }

   ul {
     list-style-type: square;
     background:  repeat-y;
     padding: 0;
     margin-left: 2vw;
   }



   ul.tree a:hover {
    background: lightgray;
    text-decoration: none;
    display: inline-block;
    width: 100%;
   }


table th { padding:1.2vw 1vw; text-align:left; vertical-align:middle; border: 1px solid #d6d4d4; font-weight:bold; }
table td { padding:1.2vw 1vw; text-align:left; vertical-align:top; border:1px solid #d6d4d4; }
table td.lfig { padding:1.2vw 1vw;  align:center; vertical-align:middle;  border:0px solid #d6d4d4; }
ul {
    list-style-type: circle;
}

ul.tree a {
    color: back;
    text-decoration: none;
    display: block;
    width: 100%;
}

  li {
     list-style-type: square;
   }
</style>
</head>
<body> 
<img class="logo" src="ValoMC_logo.png" min-width="100%">
<ul class="topnav">
<font size="4">
  <li><a href="index.html">Home</a></li>
  <li><a href="download.html">Download</a></li>
  <li><a href="features.html">Features</a></li>
  <li><a class="active" href="installation.html">Installation</a></li>
  <li><a href="documentation.html">Documentation</a></li>
  <li class="right"><a href="about.html">About</a></li>
</font>
</ul>
<div style="padding:0 1vw;  ">
  <h2></h2>
  <p></p>
  <p></p>
<div class="document">
<div class="contents topic" id="table-of-contents">
<p class="topic-title first">Table of Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#simple-installation" id="id1">Simple installation</a></li>
<li><a class="reference internal" href="#advanced-installation" id="id2">Advanced installation</a><ul>
<li><a class="reference internal" href="#cmake-compilation" id="id3">CMake compilation</a></li>
<li><a class="reference internal" href="#compiling-the-external-executable-manually" id="id4">Compiling the external executable manually</a></li>
<li><a class="reference internal" href="#multithread-parallel-compilation-from-matlab-commmand-prompt" id="id5">Multithread (parallel) compilation from MATLAB commmand prompt</a></li>
</ul>
</li>
<li><a class="reference internal" href="#how-to-obtain-a-suitable-compiler" id="id6">How to obtain a suitable compiler</a><ul>
<li><a class="reference internal" href="#windows" id="id7">Windows</a></li>
<li><a class="reference internal" href="#ubuntu" id="id8">Ubuntu</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="simple-installation">
<h1><a class="toc-backref" href="#id1">Simple installation</a></h1>
<ol class="arabic simple">
<li>Obtain the latest source code using git or direct <a class="reference external" href="https://github.com/InverseLight/ValoMC/archive/master.zip" onclick="gtag('event', 'Software Download', {'event_category': 'Master.zip'});">download</a>.</li>
</ol>
<pre class="code bash literal-block">
git clone https://github.com/InverseLight/ValoMC/
</pre>
<ol class="arabic simple" start="2">
<li>Open MATLAB and type</li>
</ol>
<pre class="code matlab literal-block">
<span class="name">addpath</span><span class="punctuation">(</span><span class="literal string">'ValoMC/'</span><span class="punctuation">)</span>
</pre>
<p>where ValoMC/ is the the folder from the zip archive or obtained using git.</p>
<ol class="arabic simple" start="3">
<li>Type</li>
</ol>
<pre class="code bash literal-block">
<span class="name builtin">cd</span> ValoMC
compile_vmc_mex
</pre>
<p>to compile mex files for MATLAB.  This assumes that a working C++
compiler has been installed and compiles a serial version of the
code. See below on instructions how to obtain a suitable compiler such
as GCC and how to compile the parallel version.</p>
<p>You can now run the examples in the examples/ -folder.
The next time you use ValoMC, the mex files will be already
compiled and you simply need to repeat step 2 to continue using
ValoMC.</p>
<ol class="arabic simple" start="4">
<li>Test the installation</li>
</ol>
<p>Try to run e.g. simpletest.m.</p>
<pre class="code matlab literal-block">
<span class="name">cd</span> <span class="name">examples</span>
<span class="name">simpletest</span>
</pre>
<p>If you receive error messages, it most likely means the mex compiler
has not yet been set up in MATLAB.  Messages along the lines 'libstdc++.so.6: version GLIBCXX_3.4.21 not found'
means that MATLAB does not support the GCC version.
For instructions how to compile the mex files with another GCC
version, see 'How to obtain a suitable compiler'.</p>
</div>
<div class="section" id="advanced-installation">
<h1><a class="toc-backref" href="#id2">Advanced installation</a></h1>
<div class="section" id="cmake-compilation">
<h2><a class="toc-backref" href="#id3">CMake compilation</a></h2>
<p>CMake is a program that can automatize the compilation process. It can
be obtained <a class="reference external" href="https://cmake.org">here</a>. ValoMC can then be installed
from command prompt, at 'ValoMC/'</p>
<pre class="code bash literal-block">
cmake .
cmake --build .
</pre>
<p>This will build the external executables as well as the mex files. It
will try to compile the parallel versions. If problems persist, see
below how to compile the external executable and the mex files
manually and how to obtain a suitable compiler. To use CMake with
another compiler, you can use e.g.</p>
<pre class="code bash literal-block">
cmake -DCMAKE_CXX_COMPILER<span class="operator">=</span>/usr/bin/g++-4.9
cmake --build .
</pre>
</div>
<div class="section" id="compiling-the-external-executable-manually">
<h2><a class="toc-backref" href="#id4">Compiling the external executable manually</a></h2>
<p>The external executable can be used to run ValoMC e.g. on a cluster
without MATLAB (see example: 'Generating input for the external
executable'). The source code for the external executables are located
in 2d/cpp/ and 3d/cpp/. These folders contain Ubuntu makefiles for
reference. CMake also builds the external executables. The 2D code
can be manually built using</p>
<pre class="code bash literal-block">
g++ MC2D.cpp -o MC2D.a -O3
</pre>
<p>The multi-threaded (OpenMP) version can be compiled with</p>
<pre class="code bash literal-block">
g++ MC2D.cpp -o MC2D.a -O3 -DUSE_OMP -fopenmp
</pre>
<p>Generalization to other compilers than GNU ones should be straightforward.</p>
</div>
<div class="section" id="multithread-parallel-compilation-from-matlab-commmand-prompt">
<h2><a class="toc-backref" href="#id5">Multithread (parallel) compilation from MATLAB commmand prompt</a></h2>
<p>Linux (gcc): To compile with OpenMP (multithread) support (from MATLAB prompt, at 'ValoMC/'):</p>
<pre class="code matlab literal-block">
<span class="name">mex</span>   <span class="operator">-</span><span class="name">DUSE_OMP</span> <span class="name">cpp</span><span class="operator">/</span><span class="literal number integer">2</span><span class="name">d</span><span class="operator">/</span><span class="name">MC2Dmex</span><span class="punctuation">.</span><span class="name">cpp</span> <span class="name">COMPFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$COMPFLAGS -fopenmp'</span> <span class="name">CXXFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$CXXFLAGS -fopenmp'</span> <span class="name">LDFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$LDFLAGS -fopenmp'</span>
<span class="name">mex</span>   <span class="operator">-</span><span class="name">DUSE_OMP</span> <span class="name">cpp</span><span class="operator">/</span><span class="literal number integer">3</span><span class="name">d</span><span class="operator">/</span><span class="name">MC3Dmex</span><span class="punctuation">.</span><span class="name">cpp</span> <span class="name">COMPFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$COMPFLAGS -fopenmp'</span> <span class="name">CXXFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$CXXFLAGS -fopenmp'</span> <span class="name">LDFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$LDFLAGS -fopenmp'</span>
</pre>
<p>Windows (Visual Studio):</p>
<pre class="code matlab literal-block">
<span class="name">mex</span>   <span class="operator">-</span><span class="name">DUSE_OMP</span> <span class="name">cpp</span><span class="operator">/</span><span class="literal number integer">2</span><span class="name">d</span><span class="operator">/</span><span class="name">MC2Dmex</span><span class="punctuation">.</span><span class="name">cpp</span> <span class="name">COMPFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$COMPFLAGS /openmp /O2'</span> <span class="name">CXXFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$CXXFLAGS '</span> <span class="name">LDFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$LDFLAGS '</span>
<span class="name">mex</span>   <span class="operator">-</span><span class="name">DUSE_OMP</span> <span class="name">cpp</span><span class="operator">/</span><span class="literal number integer">3</span><span class="name">d</span><span class="operator">/</span><span class="name">MC3Dmex</span><span class="punctuation">.</span><span class="name">cpp</span> <span class="name">COMPFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$COMPFLAGS /openmp /O2'</span> <span class="name">CXXFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$CXXFLAGS '</span> <span class="name">LDFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$LDFLAGS '</span>
</pre>
</div>
</div>
<div class="section" id="how-to-obtain-a-suitable-compiler">
<h1><a class="toc-backref" href="#id6">How to obtain a suitable compiler</a></h1>
<p>MATLAB MEX system must be set up before installing ValoMC. It needs to have
an external C++ compiler to work.</p>
<div class="section" id="windows">
<h2><a class="toc-backref" href="#id7">Windows</a></h2>
<p>For example, the TDM gcc compiler can be obtained from this
<a class="reference external" href="http://tdm-gcc.tdragon.net/download">site</a>.</p>
<p>After installation you can use</p>
<pre class="code matlab literal-block">
<span class="name">setenv</span><span class="punctuation">(</span><span class="literal string">'MW_MINGW64_LOC'</span><span class="punctuation">,</span><span class="literal string">'C:\TDM-GCC-64'</span><span class="punctuation">);</span>
<span class="name">mex</span> <span class="operator">-</span><span class="name">setup</span>
</pre>
<p>to inform MATLAB of the location. Alternatively, Visual Studio can be obtained
following this <a class="reference external" href="https://visualstudio.microsoft.com">link</a>.</p>
</div>
<div class="section" id="ubuntu">
<h2><a class="toc-backref" href="#id8">Ubuntu</a></h2>
<p>To get gcc in Ubuntu you can use</p>
<pre class="code bash literal-block">
sudo apt-get install g++
sudo apt-get install gcc
</pre>
<p>in shell. Depending on your MATLAB, it might be necessary to obtain an
older version of the compiler. For example, if MATLAB supports g++ 4.9
you can install it by</p>
<pre class="code bash literal-block">
sudo apt-get install g++-4.9
sudo apt-get install gcc-4.9
</pre>
<p>and use e.g. (from MATLAB prompt, at 'ValoMC/'):</p>
<pre class="code matlab literal-block">
<span class="name">mex</span>  <span class="operator">-</span><span class="name">v</span> <span class="name">GCC</span><span class="punctuation">=</span><span class="literal string">'/usr/bin/gcc-4.9'</span> <span class="operator">-</span><span class="name">DUSE_OMP</span> <span class="name">cpp</span><span class="operator">/</span><span class="literal number integer">2</span><span class="name">d</span><span class="operator">/</span><span class="name">MC2Dmex</span><span class="punctuation">.</span><span class="name">cpp</span> <span class="name">COMPFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$COMPFLAGS -fopenmp'</span> <span class="name">CXXFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$CXXFLAGS -fopenmp'</span> <span class="name">LDFLAGS</span><span class="punctuation">=</span><span class="literal string">'\$LDFLAGS -fopenmp'</span>
</pre>
<p>to compile the mex files.</p>
</div>
</div>
</div>
</div>
<script>
document.body.style.fontSize = (screen.width*0.008).toString() + "px";
</script>

<br>
<br> </div><footer> <hr> <p>Last updated: Fri Jun  7 17:50:28 EEST 2019 by aleksle</p></footer> </body> </html>
